/**
 * 
 */
package com.p2p.base.util;

import java.util.ArrayList;

import org.apache.commons.collections.CollectionUtils;

import com.p2p.base.bizInterface.ChangeNotify;

/**
 * @author ruiqi
 *
 */
public class ChangeNotifyUtil {
	
	public final static void addListener(String subject,ChangeNotify item){
		if(ChangeNotify.notifySubject.get(subject)==null){
			ChangeNotify.notifySubject.put(subject, new ArrayList<ChangeNotify>());
		}
		ChangeNotify.notifySubject.get(subject).add(item);
	}
	
	public final static void notify(String subject){
		if(CollectionUtils.isNotEmpty(ChangeNotify.notifySubject.get(subject))){
			for(ChangeNotify notify:ChangeNotify.notifySubject.get(subject)){
				notify.change();
			}
		}
		
	}
	
}
